<%--
  Created by IntelliJ IDEA.
  User: 小川
  Date: 2021/1/10
  Time: 16:33
  To change this template use File | Settings | File Templates.
--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script type="text/javascript" src="/js/jquery-1.8.3.min.js" ></script>
</head>
<body>
<div align="center">
    <form action="/user" method="post" id="queryForm1">
        <input type="hidden" name="page" id="page">
        请输入查询名:<input type="text" name="name" value="${user.name}">
        <input type="submit" value="查询">
    </form>
<table width="400px" height="100px" align="center" cellspacing="0px" border="1px" style="background-color: yellow">
    <thead>
    <tr align="center">
        <td><input type="checkbox" id="chkAll">全选</td>
        <td>id</td>
        <td>用户名</td>
        <td>密码</td>
        <td>年龄</td>
        <td>阶层</td>
        <td>操作</td>
    </tr>
    </thead>
    <tbody>
    <c:forEach items="${pageInfo.list}" var="map">
        <tr align="center">
            <td><input type="checkbox" name="chk" value="${map.id}"></td>
            <td>${map.id}</td>
            <td>${map.name}</td>
            <td>${map.pwd}</td>
            <td>${map.age}</td>
            <td>${map.older.jc}</td>
            <td>
                <a href="/user/toupdUser?id=${user.id}">修改</a>
            </td>
        </tr>
    </c:forEach>
    </tbody>

</table>
    共${pageInfo.pages}页/当前第${pageInfo.pageNum}
    <a href="javascript:void(0)" onclick="queryForm(1)">首页</a>
    <a href="javascript:void(0)" onclick="queryForm(${pageInfo.prePage})">上一页</a>
    <a href="javascript:void(0)" onclick="queryForm(${pageInfo.nextPage})">下一页</a>
    <a href="javascript:void(0)" onclick="queryForm(${pageInfo.pages})">尾页</a>
    <input type="text" name="page" id="numpage">
    <input type="button"  onclick="goQueryForm()" value="跳转">
</div>
</body>
<script type="text/javascript">
        $(function(){
            $("#chkAll").click(function(){
                var Allid=document.getElementById("chkAll")
                var id=document.getElementsByName("chk")
                for (var i=0;i<id.length;i++){
                    id[i].checked=Allid.checked;
                }
            });
            $("#deleteRows").click(function () {
                var num=0;
                var arrs=[];
                var ids=document.getElementsByName("chk")
                for (var i=0;i<ids.length;i++){
                    if(ids[i].checked==true){
                        arrs.push(ids[i].value)
                        num=num+1
                    }

                }
                if (num>0){
                    window.location.href="/user/delUser?ids="+arrs
                }else {
                    alert("请选择行")
                }
            })
        })
    function queryForm(num) {
        document.getElementById("page").value=num;
        document.getElementById("queryForm1").submit();
    }
    function goQueryForm(num) {
        document.getElementById("page").value=document.getElementById("numpage").value;
        document.getElementById("queryForm1").submit();
    }
</script>
</html>
